﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.WmsManagement;
using Digitalmes.Model;

using Digitalmes.Model.WmsManagement;


namespace Digitalmes.ViewModel.WmsManagement.StoreTransferVMs
{
    public partial class StoreTransferSheetDetailListVM1 : BasePagedListVM<StoreTransfer, StoreTransferDetailSearcher1>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("StoreTransfer", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("StoreTransfer", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<StoreTransfer>> InitGridHeader()
        {
            return new List<GridColumn<StoreTransfer>>{
                
                this.MakeGridHeader(x => x.MaterialId).SetEditType(EditTypeEnum.ComboBox,DC.Set<MaterialDoc>().GetSelectListItems(Wtm, x => x.TenantCode,SortByName:true)).SetTitle(@Localizer["Page.调拨物料"].Value),
                this.MakeGridHeader(x => x.MaterialName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.调拨物料"].Value),
                this.MakeGridHeader(x => x.Qty).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.调拨数量"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<StoreTransfer> GetSearchQuery()
        {
                
            var id = (long?)Searcher.SheetId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<StoreTransfer>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<StoreTransfer>()
                .Where(x => id == x.SheetId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class StoreTransferDetailSearcher1 : BaseSearcher
    {
        
        [Display(Name = "_Model._StoreTransfer._Sheet")]
        public string SheetId { get; set; }
    }

}

